/**
 * 复选框设置
 */
function scCheckboxSetting(){
    var opt = null;
    var com = scCommon.instance();
    var crEle = com.crEle;
    
    /**
     * 属性选项
     */
    var items = [
        {label: "编码(id)：", value: "id", placeholder: "唯一编码"}, 
        {label: "名称：", value: "name", placeholder: "可重复"}, 
        {label: "显示文本：", value: "title", placeholder: "请输入"}, 
        {label: "数据源名称：", value: "datasourcename", placeholder: "数据源名称"}, 
        {label: "数据源字段：", value: "datasourcefield", placeholder: "字段名称, 内容取自该字段"}
    ];

    /**
     * 容器
     */
    var box = null;

    /**
     * 设置参数
     * @param {*} option 
     */
    this.setOption = function(option){
        opt = option;
    }
    
    /**
     * 创建视图
     */
    this.createView = function(option){
        box = crEle(null, "sc-checkbox-setting");
        
        option = option ? option : {};
        listener = option.listener;

        var row = null;
        var label = null;
        var input = null;
        var data = opt && opt.data ? opt.data : null;

        var item = null;
        for(var i in items){
            item = items[i];

            row = crEle("div", "sc-checkbox-setting-row");
            label = crEle("label");
            input = crEle("input");
            
            label.innerText = item.label;
            input.type = "text";
            input.name = item.value;
            input.placeholder = item.placeholder;

            if(data && data[input.name] != undefined){
                input.value = data[input.name];
            }

            row.appendChild(label);
            row.appendChild(input);
            box.appendChild(row);
        }

        com.insertScript({
            component: this,
            node: box
        }, data, {
            row: "sc-checkbox-setting-row",
        });

        return box;
    }

    /**
     * 获取设置后的数据
     */
    this.getData = function(){
        return com.getData(box);
    }

}